package cn.wolfcode.wolf2w.web.controller;
import cn.wolfcode.wolf2w.domain.Banner;
import cn.wolfcode.wolf2w.service.IBannerService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/index")//banners/query
public class IndexController {

    @Autowired
    private IBannerService bannerService;

//查询首页的轮播图(前5个banner对象的封面字段)
    @GetMapping("/banners/travel")
    public Object BannerTravel() {
        //查询类型是游记类型的banner对象集合
        return JsonResult.success( bannerService.queryBanner(Banner.TYPE_TRAVEL));
        }


//攻略
// 攻略广告展位(单个) 查询类型是攻略类型的banner对象集合
    @GetMapping ("/banners/strategy")
    public Object BannerStrategy(){
        //查询类型是攻略类型的banner对象集合
        List<Banner> banners = bannerService.queryBannerStrategy(Banner.TYPE_STRATEGY);
        //返回banner集合第一个攻略类型的banner对象,放在攻略广告展位
        Banner banner = banners.get(0);
        return  JsonResult.success(banner);
    }



}
